package org.monkey.example.websocket.entity.convert;


import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;
import org.monkey.example.websocket.entity.dto.SocketMsgDTO;
import org.monkey.example.websocket.entity.form.SocketMsgAddForm;
import org.monkey.example.websocket.entity.form.SocketMsgSaveForm;
import org.monkey.example.websocket.entity.form.SocketMsgUpdateForm;
import org.monkey.example.websocket.entity.po.SocketMsgPO;
import org.monkey.example.websocket.entity.vo.SocketMsgVO;
import org.monkey.socket.plugin.entity.SocketMsg;

@Mapper(componentModel = "spring", nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface SocketMsgConvert {

  SocketMsgConvert INSTANT = Mappers.getMapper(SocketMsgConvert.class);

  SocketMsgVO dto2Vo(SocketMsgDTO source);

  SocketMsgDTO po2Dto(SocketMsgPO source);

  SocketMsgDTO addForm2Dto(SocketMsgAddForm source);

  SocketMsgPO dto2Po(SocketMsgDTO source);

  SocketMsgDTO updateForm2Dto(SocketMsgUpdateForm source);

  SocketMsgDTO saveForm2Dto(SocketMsgSaveForm source);

  @Mappings({
      @Mapping(target = "params", expression = "java(cn.hutool.json.JSONUtil.toJsonStr(source.getParams()))"),
      @Mapping(target = "tags", expression = "java(cn.hutool.json.JSONUtil.toJsonStr(source.getTags()))")
  })
  SocketMsgAddForm convert2AddForm(SocketMsg source);
}
